/*
    <one line to give the program's name and a brief idea of what it does.>
    Copyright (C) <year>  <name of author>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

*/

#ifndef STATE_H
#define STATE_H

#include <vector>

class State
{
public:
    static State* find_state(unsigned long id);

    // 创建一个以id作为状态
    State(unsigned long id);

    virtual State * next();             // 返回一个较优的后续状态
    virtual State * prev();             // 返回一个最优的前序状态
    virtual unsigned long next_id() const {
        return _id + 1;
    };
    virtual unsigned long prev_id() const {
        return _id - 1;
    };
    virtual int nice() const {
        return _nice;
    };
    virtual bool operator <(const State* b) {
        return nice() < b->nice();
    };
    virtual bool operator >(const State* b) {
        return nice() >  b->nice();
    };

private:
    unsigned long _id;      // 唯一标示ID
    int _nice;              // 判断状态的良好度。

    std::vector<State*> _nexts;   // 存储所有可能的下一步的状态
    std::vector<State*> _prevs;   // 存储所有传入的状态
};

#endif // STATE_H
